import axios from 'axios'

export const state = () => ({
  data: null
})

export const mutations = {
  setData (state, n) {
    state.data = n
  }
}

// global actions
export const actions = {
  // 全局服务初始化
  async nuxtServerInit (store, { params, route, req }) {
    return axios.get('/api/food/get/cart').then((res) => {
      //code
      console.log("全局变量");
      console.log(res);
      // store.commit('setData', r.data)
    }).catch((error) => {
      console.log(error)
    })
  }
}
